# json文件的I/O操作
import json

if __name__ == '__main__':
    # 使用dict构造json对象
    student = {
        'name': 'zsa',
        'age': 16,
        'score': 99.5
    }

    # 将json对象序列化到文件中
    with open('student.json_serialization', 'w') as fout:
        json.dump(student, fout)

    print('serialize json_serialization file success!')

    # 读取json文件,将文件中的内容反序列化为json对象
    with open('student.json_serialization', 'r') as fin:
        json_obj = json.load(fin)

    print('serialize json_serialization file success!')
    print(f'content is : {json_obj}')
    print('content type is : {}'.format(type(json_obj)))
